home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / palscreen.lha / palscreen.s < prev   
Encoding:
Text File  |  1993-05-23  |  4.6 KB  |  184 lines

  1. ***********************************************************
  2. * $VER: PalScreen 1.2 (01.05.93)
  3. *
  4. * © 1993 Dancing Fool of Epsilon.
  5. *
  6. * This simple little program will open a screen in a way that is
  7. * compatable with both 1.3 and 2.0+.  It will attempt to open the
  8. * screen in PAL, if it can.  It does this using the ens_Extension
  9. * field of the ExtNewScreen structure.  I wrote it because I have
  10. * seen TOO MANY programs that require 2.0+, open a screen that
  11. * is 256 lines, but open it with the default monitor.  This is
  12. * VERY annoying!  It is also very easy to fix. :)
  13. *
  14. * If it can not open a PAL screen, it opens in the default mode,
  15. * but it opens an AUTOSCROLL screen.  Either way, no data is lost
  16. * off the bottom!
  17. *
  18. * You can contact me at the following INet address:
  19. *    idr@rigel.cs.pdx.edu
  20. *
  21. * You can contact Epsilon at the following INet address:
  22. *    Epsilon@matrix.rain.com
  23. *
  24. ***********************************************************
  25.  
  26.         incdir    'Devel:include/'
  27.  
  28.         include    'exec/exec.i'
  29.         include    'exec/exec_lib.i'
  30.  
  31.         include    'intuition/intuition_lib.i'
  32.         include    'intuition/intuition.i'
  33.         include    'intuition/screens.i'
  34.  
  35.         include    'graphics/gfx.i'
  36.         include    'graphics/graphics_lib.i'
  37.         include    'graphics/displayinfo.i'
  38.  
  39.         include    'libraries/dos_lib.i'
  40.         include    'libraries/dos.i'
  41.  
  42.         include    'utility/tagitem.i'
  43.     
  44. ***********************************************************
  45.  
  46. NULL        equ    0
  47.  
  48. CALL        macro
  49.         jsr    _LVO\1(a6)
  50.         endm
  51.  
  52. OPENLIB        MACRO
  53.         lea    \1,a1        ; library name
  54.         move.l    #\2,d0        ; lib version
  55.         CALL    OpenLibrary
  56.         ENDM
  57.  
  58. ***********************************************************
  59.  
  60. _main:        bsr.b    OpenAll            ; open everything!
  61.         tst.l    d0            ; errors?
  62.         bne.b    .closedown        ; yup..
  63.  
  64.         move.l    #500,d1            ; ticks to wait...
  65.         CALLDOS    Delay            ; wait for a bit.
  66.  
  67. .closedown:    bsr.w    CloseAll        ; close everything!
  68.         rts
  69.  
  70. ***********************************************************
  71.  
  72. OpenAll:    movea.l    4.w,a6            ; exec base
  73.  
  74.         OPENLIB    IntuiName,34        ; open it
  75.         move.l    d0,_IntuitionBase    ; did it open?
  76.         beq.b    .errexit        ; nope.
  77.  
  78.         OPENLIB    DOSName,34        ; open it
  79.         move.l    d0,_DOSBase        ; did it open?
  80.         beq.b    .errexit        ; thppppt!
  81.  
  82.         lea    MyNewScreen,a0        ; my ExtNewScreen struct
  83.         CALLINT    OpenScreen        ; open it.
  84.         move.l    d0,MyScreen        ; did it open?
  85.         bne.b    .openwin        ; yippie!
  86.  
  87.     ; If it didn't open, it may be because they can't do PAL, so
  88.     ; we try it again but with NTSC.
  89.         tst.l    ErrorCode        ; was it a v36+ error?
  90.         beq.b    .errexit        ; no, dump out
  91.  
  92.         lea    MyNewScreen,a0        ; my screen
  93.         move.l    #NtscTagList,ens_Extension(a0)    ; the tag list ptr.
  94.         CALL    OpenScreen        ; open it.
  95.         move.l    d0,MyScreen        ; did it open?
  96.         beq.w    .errexit        ; blurg!
  97.         
  98. .openwin:    lea    MyNewWindow,a0
  99.         move.l    MyScreen,nw_Screen(a0)    ; ptr to its screen
  100.         CALL    OpenWindow
  101.         move.l    d0,MyWindow
  102.         beq.b    .errexit
  103.  
  104. .exit:        moveq    #0,d0            ; return no error
  105.         rts
  106.  
  107. .errexit:    moveq    #-1,d0            ; return error code
  108.         rts
  109.  
  110. ***********************************************************
  111.  
  112. CloseAll:    tst.l    _IntuitionBase        ; did intui open?
  113.         beq.b    .noint            ; nope.
  114.  
  115.         tst.l    MyWindow        ; did my window open?
  116.         beq.b    .nowin            ; nope.
  117.         move.l    MyWindow,a0        ; addr. of window
  118.         CALLINT    CloseWindow        ; close it.
  119.  
  120. .nowin:        tst.l    MyScreen        ; did my screen open?
  121.         beq.b    .noscr            ; nope.
  122.         move.l    MyScreen,a0        ; addr. of screen
  123.         CALLINT    CloseScreen        ; close it.
  124.  
  125. .noscr:        movea.l    a6,a1            ; addr. of intui base
  126.         CALLEXEC    CloseLibrary    ; close it
  127.  
  128. .noint:        tst.l    _DOSBase        ; did dos open?
  129.         beq.b    .nodos            ; nope.
  130.         movea.l    _DOSBase,a1        ; addr. of dos base
  131.         CALLEXEC    CloseLibrary
  132.  
  133. .nodos:        rts
  134.  
  135. ***********************************************************
  136.  
  137.         section    Screens,data
  138.  
  139. MyScreenTitle:    dc.b    'This is PAL if it can!',0
  140.  
  141. IntuiName:    INTNAME
  142. DOSName:    DOSNAME
  143.         even
  144.  
  145. MyNewScreen:    dc.w    0,0,640,256,2    ; screen dimensions
  146.         dc.b    1,2        ; pens
  147.         dc.w    HIRES_KEY
  148.         dc.w    NS_EXTENDED!CUSTOMSCREEN    ; custom screen
  149.         dc.l    NULL
  150.         dc.l    MyScreenTitle
  151.         dc.l    NULL,NULL
  152.         dc.l    PalTagList
  153.  
  154. PalTagList:    dc.l    SA_DisplayID,HIRES_KEY!PAL_MONITOR_ID
  155.         dc.l    SA_ErrorCode,ErrorCode
  156.         dc.l    TAG_DONE
  157.  
  158. NtscTagList:    dc.l    SA_DisplayID,HIRES_KEY
  159.         dc.l    SA_AutoScroll,DOSTRUE
  160.         dc.l    SA_ErrorCode,ErrorCode
  161.         dc.l    SA_DClip,MyClipRect
  162.         dc.l    TAG_DONE
  163.  
  164. MyNewWindow:    dc.w    0,0,200,220    ; initial window size
  165.         dc.b    1,2        ; pens
  166.         dc.l    0        ; idcmp flags
  167.         dc.l    WFLG_SIZEGADGET!WFLG_DRAGBAR    ; window flags
  168.         dc.l    NULL,NULL,NULL,NULL,NULL    ; misc. pointers
  169.         dc.w    20,20,-1,-1    ; max and min size
  170.         dc.w    CUSTOMSCREEN    ; window (screen) type
  171.  
  172. MyClipRect:    dc.w    0,0,640,200    ; bounds of screen rectangle.
  173.  
  174. ***********************************************************
  175.  
  176.         section    pointers,data
  177.  
  178. _IntuitionBase:    dc.l    0
  179. _DOSBase:    dc.l    0
  180. MyScreen:    dc.l    0
  181. MyWindow:    dc.l    0
  182. ErrorCode:    dc.l    0
  183.         END
  184.